package BaseObject;

/**
 * ClassName: TestPerson
 * Package: BaseObject
 * Description: 比较是否为同一个类
 *
 * @Author Linshio
 * @Create 2025/3/12 21:39
 */
public class TestPerson {
    public static void main(String[] args) {
        Person one = new Person(2, "hello");
        Person two = new Person(2, "hello");
        boolean b = one.compareTo(two);
        System.out.println("b = " + b);
    }


}

class Person{
    int age;
    String name;
    Person(int age,String name){
        this.age = age;
        this.name = name;
    }
    //比较当前对象传入的对象是否相等
    public boolean compareTo(Person person){
        return this.name.equals(person.name) && this.age == person.age;
    }
}
